package com.example.exception;

import com.common.result.Result;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.security.auth.login.LoginException;
import java.sql.SQLIntegrityConstraintViolationException;
@Order(10)
@RestControllerAdvice
public class GlobalExceptionHandler {

    //全局异常处理
    @ExceptionHandler(Exception.class)
    public Result globalExceptionHandler(Exception e) {
        e.printStackTrace();
        return Result.error("服务器出错了");
    }

    //登录异常处理
    @ExceptionHandler(LoginException.class)
    public Result loginExceptionHandler(LoginException e) {
        e.printStackTrace();
        return Result.error(e.getMessage());
    }





}
